//
//  JPayWayView.m
//  HeadIndustry
//
//  Created by jun on 2017/9/7.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JPayWayView.h"

@interface JPayWayView()

@property(nonatomic, strong) UISwitch *switchBtn;

@end

@implementation JPayWayView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.opaque = NO;
        [self setUpView];
    }
    return  self;
}

- (void)setUpView {
    CALayer *img1 = [CALayer layer];
    img1.contents = (__bridge id _Nullable)([UIImage imageNamed:@"yesred.png"].CGImage);
    img1.frame = CGRectMake(15, 8, 24, 24);
    [self.layer addSublayer:img1];
    
    // 配送
    YYLabel *WXPay = [YYLabel new];
    WXPay.frame = CGRectMake(img1.right + 5, 0, 75, 40);
    WXPay.font = kFONT_TITLE(16);
    [self addSubview:WXPay];
    WXPay.text = @"微信支付";
    
    CALayer *selImg = [CALayer layer];
    selImg.contents = (__bridge id _Nullable)([UIImage imageNamed:@"yes"].CGImage);
    selImg.frame = CGRectMake(kWindowW - 15 - 18, 15 , 18, 10);
    [self.layer addSublayer:selImg];
    
    CALayer *line1 = [CALayer layer];
    line1.backgroundColor = kRGBColor(150, 150, 150).CGColor;
    line1.frame = CGRectMake(15, 40-0.5 , kWindowW - 15, 0.5);
    [self.layer addSublayer:line1];

    
    // 配送   快递  包邮
    YYLabel *modeLa = [YYLabel new];
    modeLa.frame = CGRectMake(15, line1.bottom, 90, 40);
    modeLa.font = kFONT_TITLE(16);
    [self addSubview:modeLa];
    modeLa.textAlignment = NSTextAlignmentLeft;
    modeLa.text = @"匿名购买";
    
    UISwitch *switchBtn = [[UISwitch alloc]initWithFrame:CGRectMake(kWindowW - 15 - 40, 40+5, 40, 30)];
//    switchBtn.selected = YES;
    
    [switchBtn addTarget:self action:@selector(switchBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:switchBtn];
    switchBtn.on = YES;
    
    CALayer *line2 = [CALayer layer];
    line2.backgroundColor = kRGBColor(150, 150, 150).CGColor;
    line2.frame = CGRectMake(15, 80 - 0.5, kWindowW - 15, 0.5);
    [self.layer addSublayer:line2];
}

- (void)switchBtnClick:(UISwitch *)btn
{
    [self btnClick:btn.isOn];
}

- (void)btnClick:(BOOL)isHide
{
    
    if (_isHideNameBlock) {
        _isHideNameBlock(isHide);
    }
}

@end
